/* $Id: FTDLGlyph.java 35 2006-09-26 20:24:50Z funsheep $ */
package net.sourceforge.ftgl.glyph;

import java.awt.Shape;

import net.java.games.jogl.GL;

/**
 * @author funsheep
 */
public abstract class FTDLGlyph extends FTGlyph
{

	
	private int glList = -1;

	
	/**
	 * @param glyph
	 */
	public FTDLGlyph(Shape glyph)
	{
		super(glyph);
	}


	/**
	 * {@inheritDoc}
	 */
	public void render(float x, float y, float z)
	{
		this.render(x, y, z, true);
	}

	public void render(float x, float y, float z, boolean preventDLCreation)
	{
		if (this.glList != -1)
		{
			this.gl.glCallList(this.glList);
			return;
		}
		if (!preventDLCreation)
		{
			this.glList = this.gl.glGenLists(1);
			this.gl.glNewList(this.glList, GL.GL_COMPILE_AND_EXECUTE);
		}
		this.renderGlyph(x, y, z);
		if (!preventDLCreation)
		{
			this.gl.glEndList();
		}
	}

	protected abstract void renderGlyph(float x, float y, float z);

}
